package com.dingreading.cloud.common.util.wechat;

/**
 * 微信基本配置相关
 */
public class PayConfig {

/**
 * 服务号
 * 合肥校之堡教育科技有限公司账号 2302472673@qq.com
 * www.xiaozhangbao.cn
 * 测试部署使用
 */
//    public static final String APP_ID = "wx53d8b6b7f5d0aa28";
//    public static final String APP_SECRET = "2cf9af3166d9e92feb8b27ef46e53750";
//    public static final String MCH_ID = "1530259481";
//    public static final String MCH_KEY = "tcpl1201tcpl1201tcpl1201tcpl1201";

    /**
     * 服务号
     * 安徽行知至千教育科技有限公司 2793847610@qq.com
     * 生产部署使用
     */
//    public static final String APP_ID = "wx243a591295ffe76a";
//    public static final String APP_SECRET = "617ba2ddedbae5049530671e57cf0d89";
//    public static final String MCH_ID = "1516957871";
//    public static final String MCH_KEY = "tcpl1201tcpl1201tcpl1201tcpl1201";


    /**
     * 叮叮书房小程序
     */
    public static final String MINI_ID = "wxeae8697aaa3ec745";
    public static final String MINI_SECRET = "e47abd8a3334608131ca757b0b8ce06a";


    /**
     * 服务号基本配置
     */
    public static final String TOKEN = "tcpltcpltcpl";
    public static final String ENCODING_AES_KEY = "YDX8lVQZHL5QDWtflB4z4aDdhfjND7NUrPEJrG2LlcN";


    /**
     * 微信商户api证书路径，测试证书地址
     */
    public static final String CERT_URL = "/home/verify/apiclient_cert.p12";

    /**
     * 微信商户api证书路径，生成证书地址
     */
//    public static final String CERT_URL = "/home/verify/apiclient_cert.p12";

    /**
     * 临时二维码
     */
    public final static String QR_SCENE = "QR_SCENE";

    /**
     * 永久二维码
     */
    public final static String QR_LIMIT_SCENE = "QR_LIMIT_SCENE";

    /**
     * 微信返回成功的标志
     */
    public static final String RETURN_SUCCESS = "SUCCESS";

    /**
     * 授权后回调地址
     */
    public static String getAfterAuthorizeReturnUrl(String notifyUrl) {
        return notifyUrl + "/wx/wxPay/pay";
    }

    /**
     * 支付地址(包涵回调地址)
     */
//    public static final String PAY_URL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + util.appId + "&redirect_uri=" + AFTER_AUTHORIZE_RETURN_URL + "&response_type=code&scope=snsapi_userinfo#wechat_redirect";
    public static String getPayUrl(String appId, String notifyUrl) {
        return "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appId + "&redirect_uri=" + getAfterAuthorizeReturnUrl(notifyUrl) + "&response_type=code&scope=snsapi_userinfo#wechat_redirect";
    }

    /**
     * 支付成功后回调地址
     */
    public static String getWxNotifyUrl(String notifyUrl) {
        return notifyUrl + "/payCallback/wxpay/notifyUrl";
    }

    /**
     * 退款结果回调地址
     */
    public static String getRefundNotifyUrl(String notifyUrl) {
        return notifyUrl + "/wx/wxPay/refundNotifyUrl";
    }

    /**
     * 证书路径,注意应该填写绝对路径（仅退款、撤销订单时需要）
     */
    public static String getCertUrl(String notifyUrl) {
        return notifyUrl + "/cert/apiclient_cert.p12";
    }

    /**
     * APP-支付成功后回调地址
     */
    public static String getPaySuccessReturnMsg(String notifyUrl) {
        return notifyUrl + "/api/wxPay/notifyUrl";
    }

    /**
     * 微信授权的地址
     */
    public static final String GET_AUTHORIZE = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect";

    /**
     * 用户网页授权通过code获取access_token的URL
     */
    public static final String GET_AUTHTOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?";

    /**
     * 获取appid和secret获取微信访问access_token字符串基础接口的URL
     */
    public static final String GET_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s";

    /**
     * 通过accessToken获取调用微信JS接口的临时票据jsApiTicket的URL
     */
    public static final String GET_JS_API_TICKET_URL = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi";

    /**
     * 通过jsApiTicket获取微信JS-SDK使用权限签名的URL
     */
    public static final String GET_JS_API_SIGNATURE_URL = "jsapi_ticket=%s&noncestr=%s&timestamp=%s&url=%s";

    /**
     * 通过accessToken和openid获取微信用户信息
     */
    public static final String USER_INFO_URL = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=%s&openid=%s&lang=zh_CN";

    /**
     * 微信统一下单url
     */
    public static final String UNIFIED_ORDER_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder";

    /**
     * 微信生成支付二维码url
     */
    public static final String SHORT_URL = "https://api.mch.weixin.qq.com/tools/shorturl";

    /**
     * 创建可登陆二维码的ticket
     */
    public static final String LOGIN_TICKET_URL = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=%s";

    /**
     * 通过可登陆二维码ticket获取可登陆二维码
     */
    public static final String LOGIN_SHOW_QR_CODE_URL = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=%s";

    /**
     * 收到支付成功的回调后返回给微信的成功的信息
     */
    public static final String PAY_SUCCESS_RETURN_MSG = "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";

    /**
     * 收到支付成功的回调后返回给微信的签名失败的信息
     */
    public static final String SIGN_FAIL_RETURN_MSG = "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[check sign fail]]></return_msg></xml>";

    /**
     * 证微信小程序获取openid和session_key等信息
     */
    public static final String CODE2SESSION = "https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code";

    /**
     * 刷新access_token
     */
    public static final String GET_REFRESH_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=%s&grant_type=refresh_token&refresh_token=%s";

    /**
     * 网页授权拉取用户信息
     */
    public static final String GET_WEB_USER_INFO_URL = "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN";

    /**
     * 小程序关闭订单url
     */
    public static final String CLOSE_ORDER_URL = "https://api.mch.weixin.qq.com/pay/closeorder";
}